package xyz.ddlnt.user.usr.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import xyz.ddlnt.commonutil.result.Result;
import xyz.ddlnt.commonutil.util.HttpUtils;
import xyz.ddlnt.model.dto.PageDTO;
import xyz.ddlnt.model.dto.UserContentInteractionDTO;
import xyz.ddlnt.model.entity.PrivateMessageList;
import xyz.ddlnt.model.vo.PrivateMessageListVO;
import xyz.ddlnt.serviceusrclient.client.PrivateMessageListFeignClient;

import java.util.List;

/**
 * @author ZZULI_SE 210910
 * @data 2025/5/26 16:44
 */
@Slf4j
@Tag(name = "私信列表接口测试")
@RequestMapping("/private_message_list")
@RestController
public class PrivateMessageListController {
    @Resource
    private PrivateMessageListFeignClient privateMessageListFeignClient;

    @Operation(summary = "判断(并插入)私信列表")
    @PostMapping("/isExits/{bloggerId}")
    Result<Integer> JudgeAndInsertPrivateMessageList(@PathVariable Long bloggerId, HttpServletRequest request) {
        UserContentInteractionDTO userContentInteractionDTO = UserContentInteractionDTO.builder()
                .userId(HttpUtils.getId(request))
                .bloggerId(bloggerId)
                .build();
        return privateMessageListFeignClient.JudgeAndInsertPrivateMessageList(userContentInteractionDTO);
    }

    @Operation(summary = "获取私信列表")
    @PostMapping("/listPrivateMessageList")
    Result<List<PrivateMessageListVO>> listPrivateMessageList(@RequestBody PageDTO pageDTO, HttpServletRequest request) {
        pageDTO.setId(HttpUtils.getId(request));
        return privateMessageListFeignClient.listPrivateMessageList(pageDTO);
    }

    @Operation(summary = "删除私信")
    @DeleteMapping("/deletePrivateMessage")
    Result<Boolean> deletePrivateMessage(@RequestBody UserContentInteractionDTO userContentInteractionDTO, HttpServletRequest request) {
        userContentInteractionDTO.setUserId(HttpUtils.getId(request));
        return privateMessageListFeignClient.deletePrivateMessage(userContentInteractionDTO);
    }

}
